#pragma once
#include "bp/bp_platform.h"

typedef struct _bp_u8string_t *bp_u8string_t;

typedef struct _bp_string_enumerate_state {
	union {
		bp_u8string_t u8;
	}string;

	union {
		const bp_char8_t *u8;
	}current;

	bp_bool end_of_string;
	bp_char32_t charater;
}bp_string_enumerate_state;

_BP_INLINE void _BP_API bp_string_enumerate_state_init(bp_string_enumerate_state *state)
{
	if (!state)
	{
		return;
	}

	memset(state, 0, sizeof(bp_string_enumerate_state));
	state->end_of_string = BP_FALSE;
}

_BP_EXPORT bp_u8string_t _BP_API bp_u8string_from_bytes(const bp_byte_t *bytes, size_t size, bp_string_encode encode);

_BP_EXPORT const bp_char8_t * _BP_API bp_u8string_get_cstr(const bp_u8string_t string);
_BP_EXPORT size_t _BP_API bp_u8string_length(const bp_u8string_t string);

_BP_EXPORT bp_bool _BP_API bp_u8string_next_u8char(bp_u8string_t string, bp_string_enumerate_state *state); 
_BP_EXPORT bp_bool _BP_API bp_u8string_next_codepoint(bp_u8string_t string, bp_string_enumerate_state *state);

_BP_EXPORT void _BP_API bp_u8string_free(bp_u8string_t string);